Micron Document
πŸŽ–οΈGitΠ―Ρ€Π°πŸŽ–οΈ


Displaying Raw β€’ View rendered β€’ Download

feature/discovery/README.md fix/fdroid-map-rendering (113121c4) Text, 4.45 KB

Tc9d1d9# `:feature:discovery`

Tc9d1d9## Overview

The Ta5d6ff`:feature:discovery` module implements **Local Mesh Discovery**: the app cycles the connected radio through a queue of LoRa modem presets, dwells on each for a configured duration while collecting packets, then persists and ranks the results so the user can see which preset (or beacon-advertised custom channel) has the most active mesh nearby. Sessions are stored via Ta5d6ff`DiscoveryDao` and can be revisited, mapped, summarised (AI or algorithmic), and exported.

**Targets:** Android Β· JVM (Desktop) Β· iOS (via Ta5d6ff`meshtastic.kmp.feature` convention plugin)

Tc9d1d9## Scan Workflow

Tff7b72- Ta5d6ff`DiscoveryScanEngine` β€” core scan engine. Cycles through a queue of Ta5d6ff`ScanTarget`s, dwells on each while collecting packets, and persists aggregated results via Ta5d6ff`DiscoveryDao`.
Tff7b72- Ta5d6ff`DiscoveryScanState` β€” state machine for the scan lifecycle: Ta5d6ff`Idle β†’ Preparing β†’ Shifting β†’ [Reconnecting] β†’ Dwell β†’ … β†’ Analysis β†’ Complete`, with Ta5d6ff`Cancelling`/Ta5d6ff`Restoring`/Ta5d6ff`Failed`/Ta5d6ff`Paused` side paths.
Tff7b72- Ta5d6ff`ScanTarget` β€” one queue entry. Ta5d6ff`channel == null` is a public-preset target; a non-null channel is a beacon-advertised custom channel: the engine tunes the radio's primary channel to that name+PSK (and region) for the dwell, then restores it.
Tff7b72- Ta5d6ff`DiscoveryRankingEngine` (Ta5d6ff`scan/`) β€” ranks preset results by unique node count, neighbor diversity, non-duplicate packet count, and SNR.
Tff7b72- Ta5d6ff`Check24GhzCapability` (Ta5d6ff`scan/`) β€” layered heuristic that determines whether the connected radio supports 2.4 GHz LoRa (SX1280), returning Ta5d6ff`Supported` / Ta5d6ff`Unsupported` / Ta5d6ff`Unknown`.

Tc9d1d9## ViewModels & Screens

| ViewModel | Screen (Ta5d6ff`ui/`) | Purpose |
|---|---|---|
| Ta5d6ff`DiscoveryViewModel` | Ta5d6ff`DiscoveryScanScreen` | Scan setup and live progress (drives Ta5d6ff`DiscoveryScanEngine`) |
| Ta5d6ff`DiscoverySummaryViewModel` | Ta5d6ff`DiscoverySummaryScreen` | Post-scan session summary, ranking, and export |
| Ta5d6ff`DiscoveryMapViewModel` | Ta5d6ff`DiscoveryMapScreen` | Discovered-node map with per-preset filter chips (rendered via Ta5d6ff`LocalDiscoveryMapProvider` from Ta5d6ff`core:ui`) |
| Ta5d6ff`DiscoveryHistoryViewModel` | Ta5d6ff`DiscoveryHistoryScreen` | Past session list with delete |
| Ta5d6ff`DiscoveryHistoryDetailViewModel` | Ta5d6ff`DiscoveryHistoryDetailScreen` | Detail view of one stored session |

Navigation entries are registered by Ta5d6ff`discoveryGraph()` in Ta5d6ff`navigation/DiscoveryNavigation.kt` (Navigation 3, Ta5d6ff`DiscoveryRoute.*` keys).

Tc9d1d9## Summary Layer: AI vs Algorithmic

Same Google-flavor Gemini Nano vs fallback split as Ta5d6ff`:feature:docs`:

Tff7b72- Ta5d6ff`ai/DiscoverySummaryAiProvider` β€” interface for natural-language session/preset summaries.
Tff7b72- Ta5d6ff`ai/AlgorithmicSummaryProvider` β€” deterministic fallback delegating to Ta5d6ff`DiscoverySummaryGenerator`. Registered with Ta5d6ff`binds = []`; each platform binds the interface explicitly: the Android Ta5d6ff`google` flavor binds Ta5d6ff`GeminiNanoSummaryProvider` (in Ta5d6ff`:androidApp`), while Ta5d6ff`fdroid`, Desktop, and iOS bind the algorithmic provider.
Tff7b72- Ta5d6ff`ai/LoRaPresetReference` β€” modem-preset reference data (bandwidth, spreading factor, link budget) used to enrich AI prompts and algorithmic summaries.

Tc9d1d9## Export

Multiplatform export path in Ta5d6ff`export/`:

Tff7b72- Ta5d6ff`DiscoveryExporter` β€” interface: Ta5d6ff`export(DiscoveryExportData): ExportResult` (success = bytes + MIME type + filename).
Tff7b72- Ta5d6ff`DiscoveryReportFormatter` β€” shared formatting of session/preset report lines and filenames.
Tff7b72- Ta5d6ff`rememberExportSaver()` / Ta5d6ff`ExportSaverLauncher` β€” Ta5d6ff`expect`/Ta5d6ff`actual` file-save seam per platform (Ta5d6ff`ExportSaver.android.kt` β†’ SAF document picker, Ta5d6ff`ExportSaver.jvm.kt` β†’ file dialog, Ta5d6ff`ExportSaver.ios.kt`).
Tff7b72- Ta5d6ff`PdfDiscoveryExporter` (androidMain) renders a PDF report; Ta5d6ff`TextDiscoveryExporter` (jvmMain) renders plain text.

Tc9d1d9## Mesh Beacon Invitations

UI for port-37 Mesh Beacon join invitations (Ta5d6ff`ui/component/`):

Tff7b72- Ta5d6ff`MeshBeaconInvitationCard` β€” a received beacon offer with its advertised channel/region/preset; the user can survey the mesh first, join it, or dismiss. Shown on Ta5d6ff`DiscoveryScanScreen`.
Tff7b72- Ta5d6ff`BeaconChannelsCard` β€” scan-setup section listing distinct beacon-advertised custom channels; selecting a row adds a custom-channel Ta5d6ff`ScanTarget`.

Tc9d1d9## Key Dependencies

From Ta5d6ff`feature/discovery/build.gradle.kts` (Ta5d6ff`commonMain`):

Tff7b72- Ta5d6ff`core:common`, Ta5d6ff`core:data`, Ta5d6ff`core:database`, Ta5d6ff`core:di`, Ta5d6ff`core:model`, Ta5d6ff`core:navigation`, Ta5d6ff`core:network`, Ta5d6ff`core:prefs`, Ta5d6ff`core:repository`, Ta5d6ff`core:resources`, Ta5d6ff`core:service`, Ta5d6ff`core:ui`
Tff7b72- Ta5d6ff`kotlinx.collections.immutable`
Tff7b72- Ta5d6ff`org.meshtastic:protobufs` (Maven artifact)

Served by rngit 1.5.2 - Generated in 0.05s